<template>
  <!-- 文章详情 -->
  <view class="setting-page" :style="my_style">
    <u-parse :html="info.content"></u-parse>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        type: '',
        id: '',
        info: '',
      }
    },
    onLoad(options) {
      this.type = options.type || ''
      this.id = options.id || ''
      this.tag = options.tag || ''
      if (this.type === 'help') {
        this.getHelpInfo()
      } else {
        this.getArticle()
      }
    },
    methods: {
      /**
       * 获取帮助文章详情
       */
      async getHelpInfo() {
        let params = {
          id: this.id,
        }
        const res = await this.$api.common.system('getHelpInfo', params)
        if (res.code === 200) {
          const { class_name } = res.data
          this.info = res.data
          uni.setNavigationBarTitle({
            title: class_name,
          })
        }
      },
      /**
       * 特殊文章
       */
      async getArticle() {
        const res = await this.$api.common.document(this.tag)
        if (res.code === 200) {
          const { class_name } = res.data
          this.info = res.data
          uni.setNavigationBarTitle({
            title: class_name,
          })
        }
      },
    },
  }
</script>

<style lang="scss" scoped>
  .setting-page {
    height: 100%;
    padding: 24rpx;
    background: #fff;
  }
</style>
